import java.text.NumberFormat;
import java.util.Scanner;

public class Calculator {
    public static void main(String[] args) {
        /*
        System.out.println("Hello,world");
        var s=System.in.read();
                System.out.println("姓名\t性别\t籍贯\t住址\n蒋林康\t男\t湖南\t零陵区");
        */
        //Scanner scanner = new Scanner(System.in);
//        Scanner scanner = new Scanner(System.in);
//        System.out.println("请输入本金");
//        double p = scanner.nextDouble();
//        if (p > 0) {
//            System.out.println("请输入年利率");
//            double yr = scanner.nextDouble();
//            if (yr >= 1.0 && yr <= 36.0) {
//                double mr = yr / 12 / 100;
//                System.out.println("请输入还款月数");
//                int m = scanner.nextInt();
//                if (m >= 1 && m <= 360) {
//                    double pow = Math.pow(1 + mr, m);
//                    double payment = p * mr * pow / (pow - 1);
//                    System.out.println("每月还款金额");
//                    System.out.println(NumberFormat.getCurrencyInstance().format(payment));
//                } else {
//                    System.out.println("贷款月数必须是1~360");
//                }
//            } else {
//                System.out.println("年利率必须是1%~36%");
//            }
//        } else {
//            System.out.println("贷款金额必须大于0");
//        }
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入本金");
        double p = scanner.nextDouble();
        if (p <= 0) {
            System.out.println("贷款金额必须大于0");
            return;
        }
        System.out.println("请输入年利率");
        double yr = scanner.nextDouble();
        if (yr < 1.0 || yr > 36.0) {
            System.out.println("年利率必须是1%~36%");
            return;
        }
        double mr = yr / 12 / 100;
        System.out.println("请输入还款月数");
        int m = scanner.nextInt();
        if (m < 1 || m > 360) {
            System.out.println("贷款月数必须是1~360");
            return;

        }
        double pow = Math.pow(1 + mr, m);
        double payment = p * mr * pow / (pow - 1);
        System.out.println("每月还款金额");
        System.out.println(NumberFormat.getCurrencyInstance().format(payment));

//        String format = NumberFormat.getCurrencyInstance().format(100.0);
//        System.out.println(format);
    }
}
